package com.example.privacy.Utils;

import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferencesUtils {
    private SharedPreferences share;
    private SharedPreferences.Editor editor;
    private String SHARED_NAME = "logindata";


    private SharedPreferencesUtils(Context context){
        share = context.getSharedPreferences(SHARED_NAME,Context.MODE_PRIVATE);
        editor = share.edit();
    }

    private static SharedPreferencesUtils instance;
    public static SharedPreferencesUtils getInstance(Context context){
        if(instance == null){
            synchronized (SharedPreferencesUtils.class){
                if(instance == null){
                    instance = new SharedPreferencesUtils(context);
                }
            }
        }
        return instance;
    }
    public void putString(String name, String value){
        editor.putString(name, value);
        editor.commit();
    }
    public String getString(String name, String defaultValue){
        return share.getString(name, defaultValue);
    }
    public String getString(String name){
        return share.getString(name,"");
    }
}
